////
//
/// \file ./include/inc/parser/procedure_call_node.hpp
//
//  Copyright 2007, 2008 Chandler Carruth
//
//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
//  use this file except in compliance with the License.  You may obtain a copy
//  of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
//  License for the specific language governing permissions and limitations
//  under the License.
//
////

#ifndef inc_parser_procedure_call_node_header
#define inc_parser_procedure_call_node_header

#include <string>
#include <vector>

#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>

#include <inc/parser/parse_tree_node.hpp>
#include <inc/parser/ws_parser.hpp>

namespace inc {
namespace parser {

class NameNode;
class ExpressionNode;

/// \brief  Parse node for procedure calls
/// \author Chandler Carruth
/// \date   2008.05.25
///
/// This represents the n-ary analog to mutations in INC, procedure calls. Each
/// call forms a single statement-level construct which is allowed to have side
/// effects, as it is ordered w.r.t. other statements in a top-down flow of
/// execution.

class ProcedureCallNode : public ParseTreeNode
{
public:
  typedef std::vector< boost::shared_ptr< ExpressionNode > > ParameterChain;
  typedef std::vector< bool > ParameterInputFlagChain;
  typedef std::vector< bool > ParameterOutputFlagChain;

  ProcedureCallNode();
  virtual ~ProcedureCallNode();

  virtual bool parse( const iterator& first,
                      const iterator& last,
                      iterator& last_parsed );

  /// \brief Accessor for the function name
  virtual NameNode* get_name() const { return name.get(); }

  /// \brief Query the size of the parameter list
  virtual size_t parameter_list_size() const { return params.size(); }

  /// \brief Accessor for a particular parameter
  virtual ExpressionNode* parameter( int i ) const { return params[i].get(); }

  /// \brief Accessor for a particular parameter's input flag
  virtual bool parameter_is_input( int i ) const
      { return param_input_flags[i]; }

  /// \brief Accessor for a particular parameter's output flag
  virtual bool parameter_is_output( int i ) const
      { return param_output_flags[i]; }

private:
  boost::scoped_ptr< NameNode > name;
  ParameterChain params;
  ParameterInputFlagChain param_input_flags;
  ParameterInputFlagChain param_output_flags;

  boost::scoped_ptr< WSParser > ws;
};

} //  end parser namespace
} //  end inc namespace
#endif  //  inc_parser_procedure_call_node_header
